Skip to content

fix: explicit UTF-8 encoding in test _make_package helper to unblock Windows CI#1124

Merged
danielmeppiel merged 2 commits intomainfrom
copilot/fix-unicode-encoding-windows
May 3, 2026
Merged

fix: explicit UTF-8 encoding in test _make_package helper to unblock Windows CI#1124
danielmeppiel merged 2 commits intomainfrom
copilot/fix-unicode-encoding-windows

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 3, 2026

Description

On Windows, write_text() defaults to cp1252, which cannot encode the Unicode tag character \U000e0041 used in test_critical_security_finding_blocks_write, causing a UnicodeEncodeError in CI on windows-latest.

  • tests/unit/integration/test_command_integrator.py line 37: Added encoding="utf-8" to the module-level _make_package helper's write_text call, matching the identical fix already applied at line 292 in the same file.
# Before
(prompts_dir / name).write_text(content)

# After
(prompts_dir / name).write_text(content, encoding="utf-8")

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
Original prompt

CI Failure on Windows

The CI/CD Pipeline is failing on windows-latest with this error:

FAILED tests/unit/integration/test_command_integrator.py::TestCursorCommandPanelFindings::test_critical_security_finding_blocks_write - UnicodeEncodeError: 'charmap' codec can't encode character '\U000e0041' in position 39: character maps to <undefined>

Root Cause

The shared module-level _make_package helper function at line 37 of tests/unit/integration/test_command_integrator.py uses write_text(content) WITHOUT specifying encoding="utf-8". On Windows, the default encoding is cp1252, which cannot handle the Unicode tag character \U000e0041 used in the test_critical_security_finding_blocks_write test.

Fix Required

In tests/unit/integration/test_command_integrator.py, line 37, change:

(prompts_dir / name).write_text(content)

to:

(prompts_dir / name).write_text(content, encoding="utf-8")

This is a ONE LINE change. The fix is identical to what was already done at line 292 in the same file for a similar write_text call. Do NOT change anything else in the file.

Verification

After the fix, the test TestCursorCommandPanelFindings::test_critical_security_finding_blocks_write should pass on Windows since the file will be written with explicit UTF-8 encoding regardless of the platform default.

…x Windows UnicodeEncodeError

Agent-Logs-Url: https://github.com/microsoft/apm/sessions/fef5d8c7-0e07-4b3e-9b8a-3020fcdb96af

Co-authored-by: sergio-sisternes-epam <207026618+sergio-sisternes-epam@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unicode encoding issue in test_command_integrator fix: explicit UTF-8 encoding in test _make_package helper to unblock Windows CI May 3, 2026
@sergio-sisternes-epam sergio-sisternes-epam marked this pull request as ready for review May 3, 2026 18:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Windows CI failure in the unit test suite by making test fixture file-writing deterministic across platforms (avoiding the Windows default cp1252 encoding).

Changes:

  • Updated the shared _make_package test helper to write prompt files with explicit encoding="utf-8".

@danielmeppiel danielmeppiel enabled auto-merge May 3, 2026 18:28
@danielmeppiel danielmeppiel added this pull request to the merge queue May 3, 2026
Merged via the queue into main with commit 0e7d1cd May 3, 2026
27 checks passed
@danielmeppiel danielmeppiel deleted the copilot/fix-unicode-encoding-windows branch May 3, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants